﻿using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Linq;
using System.Text;
using HttpContrib;
using Microsoft.Http;
using TMShopClient.Interface;

namespace Question {
    [Export("application/question+xml", typeof(IMediaTypeHandler))]
    public class QuestionMediaTypeHandler : IMediaTypeHandler {
        private readonly IShell _Shell;

        [ImportingConstructor]
        public QuestionMediaTypeHandler(IShell shell) {
            _Shell = shell;
        }

        public IHypermediaContent GetContent(Uri baseUrl, HttpContent content) {
            return new QuestionContent(content);
        }

        public IMediaTypeController RunController(HttpResponseMessage message) {
            var ctrl = new QuestionController(_Shell);
            ctrl.Handle(message);
            return ctrl;
        }
    }
}
